-- CALC_BUY_MATERIAL_COST

-- 计算购买消耗
return function(materialList)
    -- 阶位对应的价钱
    local foodMaterial = { [1] = 0.06, [2] = 0.12, [3] = 0.3, [4] = 0.96};
    local weaponMaterial = { [1] = 0.09, [2] = 0.25, [3] = 0.375, [4] = 0.45};
    local deviceMaterial = { [1] = 0.3, [2] = 0.6, [3] = 1.2, [4] = 2.4};
    local FOOD_MATERIAL = 20;
    local WEAPON_MATERIAL = 15;
    local SLIME_MATERIAL = 17;
    local DEVICE_MATERIAL = 32;

    -- 购买消耗
    local cost = {};

    -- 获得材料的阶位和类别
    local sum = 0;
    for _, value in pairs(materialList) do
        local classId = value.classId;
        local groupId = ItemM.query(classId, "group");
        local rank = ItemM.query(classId, "rank");
        local price = 0;
        local attrib = "gem";  -- 默认都是钻石购买

        if groupId == FOOD_MATERIAL then
            price = foodMaterial[rank];
        elseif groupId == WEAPON_MATERIAL then
            price = weaponMaterial[rank];
        elseif groupId == SLIME_MATERIAL then
            -- 碎片可能不是通过钻石购买的
            local scrapPrice = MarketM.getCurScrapPrice(classId);
            attrib = scrapPrice[1];
            price = scrapPrice[2];
        elseif groupId == DEVICE_MATERIAL then
            price = deviceMaterial[rank];
        end

        -- 如果是钻石类的，单价统一乘以1000，用于计算
        if type(attrib) == "string"  and attrib == "gem" then
            price = price * 1000;
        end

        -- 总价
        local needNum = value.needNum;
        local num = needNum * price;

        if type(attrib) == "string" then
            table.insert(cost, {2, attrib, num});
        else
            table.insert(cost, {1, attrib, num});
        end
    end

    -- 统一整理一下，相同的放在一起
    cost = BonusM.combineBonus(cost);

    return cost;
end